/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Janela.java
 *
 * Created on 15/09/2010, 10:57:01
 */

package view;

import compilador.Compilador333;
import java.awt.Color;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Gabriel
 */
public class Janela extends javax.swing.JFrame {

    private Thread compilador;

    /** Creates new form Janela */
    public Janela() {
        initComponents();
        codigoFonte.setBorder(new NumberedBorder());
                       
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        jLabel1 = new javax.swing.JLabel();
        novo = new javax.swing.JButton();
        abrir = new javax.swing.JButton();
        salvar = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        executar = new javax.swing.JButton();
        cancelar = new javax.swing.JButton();
        limpar = new javax.swing.JButton();
        jButtonAjuda = new javax.swing.JButton();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextAreaErros = new javax.swing.JTextArea();
        jSplitPane1 = new javax.swing.JSplitPane();
        jTabbedPane2 = new javax.swing.JTabbedPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableTokens = new javax.swing.JTable();
        jTabbedPane3 = new javax.swing.JTabbedPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        codigoFonte = new javax.swing.JTextArea();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItemNovo = new javax.swing.JMenuItem();
        jMenuItemAbrir = new javax.swing.JMenuItem();
        jMenuItemSalvar = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        jMenuItemSair = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItemLimpar = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        jMenuItemAjuda = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Analisador Léxico Ecompilator 1.0");

        jToolBar1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(204, 204, 204)));
        jToolBar1.setRollover(true);
        jToolBar1.add(jLabel1);

        novo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/paper_48.png"))); // NOI18N
        novo.setText("Novo");
        novo.setToolTipText("Novo arquivo fonte");
        novo.setFocusable(false);
        novo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        novo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        novo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                novoActionPerformed(evt);
            }
        });
        jToolBar1.add(novo);

        abrir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/folder_48.png"))); // NOI18N
        abrir.setText("Abrir");
        abrir.setToolTipText("Abrir");
        abrir.setFocusable(false);
        abrir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        abrir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        abrir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                abrirActionPerformed(evt);
            }
        });
        jToolBar1.add(abrir);

        salvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/floppy_disk_48.png"))); // NOI18N
        salvar.setText("Salvar");
        salvar.setToolTipText("Salvar");
        salvar.setFocusable(false);
        salvar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        salvar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        salvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                salvarActionPerformed(evt);
            }
        });
        jToolBar1.add(salvar);
        jToolBar1.add(jSeparator3);

        executar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/spanner_48.png"))); // NOI18N
        executar.setText("Executar");
        executar.setToolTipText("Análise Léxica");
        executar.setFocusable(false);
        executar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        executar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        executar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                executarActionPerformed(evt);
            }
        });
        jToolBar1.add(executar);

        cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/cancel_48.png"))); // NOI18N
        cancelar.setText("Cancelar");
        cancelar.setToolTipText("Cancelar");
        cancelar.setFocusable(false);
        cancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        cancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarActionPerformed(evt);
            }
        });
        jToolBar1.add(cancelar);

        limpar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/refresh_48.png"))); // NOI18N
        limpar.setText("Limpar");
        limpar.setToolTipText("Limpar");
        limpar.setFocusable(false);
        limpar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        limpar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        limpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                limparActionPerformed(evt);
            }
        });
        jToolBar1.add(limpar);

        jButtonAjuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/questionmark_48.png"))); // NOI18N
        jButtonAjuda.setText("Ajuda");
        jButtonAjuda.setToolTipText("Estrutura Léxica da Linguagem");
        jButtonAjuda.setFocusable(false);
        jButtonAjuda.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonAjuda.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonAjuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAjudaActionPerformed(evt);
            }
        });
        jToolBar1.add(jButtonAjuda);

        jTabbedPane1.setAutoscrolls(true);

        jTextAreaErros.setColumns(20);
        jTextAreaErros.setEditable(false);
        jTextAreaErros.setRows(5);
        jScrollPane3.setViewportView(jTextAreaErros);

        jTabbedPane1.addTab("Erros", jScrollPane3);

        jTableTokens.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Linha", "Token", "Tipo", "Valor"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTableTokens.setShowVerticalLines(false);
        jScrollPane2.setViewportView(jTableTokens);

        jTabbedPane2.addTab("Tokens", jScrollPane2);

        jSplitPane1.setLeftComponent(jTabbedPane2);

        codigoFonte.setColumns(20);
        codigoFonte.setRows(5);
        codigoFonte.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        jScrollPane1.setViewportView(codigoFonte);

        jTabbedPane3.addTab("Novo Arquivo", jScrollPane1);

        jSplitPane1.setRightComponent(jTabbedPane3);

        jMenu1.setText("Arquivo");

        jMenuItemNovo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemNovo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/paper_48_menor.png"))); // NOI18N
        jMenuItemNovo.setText("Novo");
        jMenuItemNovo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemNovoActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemNovo);

        jMenuItemAbrir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemAbrir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/folder_48_menor.png"))); // NOI18N
        jMenuItemAbrir.setText("Abrir");
        jMenuItemAbrir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAbrirActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemAbrir);

        jMenuItemSalvar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItemSalvar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/floppy_disk_48_menor.png"))); // NOI18N
        jMenuItemSalvar.setText("Salvar");
        jMenuItemSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSalvarActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemSalvar);
        jMenu1.add(jSeparator2);

        jMenuItemSair.setText("Sair");
        jMenuItemSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemSairActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItemSair);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Executar");

        jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F9, java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/spanner_48_menor.png"))); // NOI18N
        jMenuItem4.setText("Análise Léxica");
        jMenu2.add(jMenuItem4);

        jMenuItem5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/cancel_48_menor.png"))); // NOI18N
        jMenuItem5.setText("Cancelar");
        jMenu2.add(jMenuItem5);

        jMenuItemLimpar.setText("Limpar");
        jMenuItemLimpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemLimparActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItemLimpar);
        jMenu2.add(jSeparator1);

        jMenuItemAjuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/questionmark_48_menor.png"))); // NOI18N
        jMenuItemAjuda.setText("Ajuda");
        jMenuItemAjuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemAjudaActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItemAjuda);

        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 915, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 928, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(2, 2, 2)
                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 926, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void salvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarActionPerformed
JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("Arquivos texto", "txt", "dat", "java"));


        int a = fileChooser.showSaveDialog(null);
       

        if (a == JFileChooser.APPROVE_OPTION) {
            File arquivo = new File(fileChooser.getSelectedFile().getAbsolutePath() + ".txt");
            FileWriter writer = null;

            try {
                writer = new FileWriter(arquivo);
                writer.write(codigoFonte.getText());
                writer.close();
            } catch (IOException exception) {
            }
             jTabbedPane3.setTitleAt(0, fileChooser.getSelectedFile().getName());


        }        // TODO add your handling code here:
    }//GEN-LAST:event_salvarActionPerformed

    private void abrirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_abrirActionPerformed
JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle("Abrir Código");
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("Arquivos textos", "txt", "dat", "java"));

        int a = fileChooser.showOpenDialog(null);
        if (a == JFileChooser.APPROVE_OPTION) {
            try {
                FileReader reader = new FileReader(fileChooser.getSelectedFile());
                BufferedReader breader = new BufferedReader(reader);
                int contador = 1;
                String line = "";
                String aux = "";
                do {
                    try {
                        line = breader.readLine();
                        if (line != null) {
                            aux = aux + line;
                            aux = aux + "\n";
                        }

                    } catch (IOException ex) {
                        Logger.getLogger(Janela.class.getName()).log(Level.SEVERE, null, ex);
                    }

                } while (line != null);
                jTabbedPane3.setTitleAt(0, fileChooser.getSelectedFile().getName());
                codigoFonte.setText(aux);
            } catch (FileNotFoundException ex) {
                Logger.getLogger(Janela.class.getName()).log(Level.SEVERE, null, ex);
            }
        }        // TODO add your handling code here:
    }//GEN-LAST:event_abrirActionPerformed

    private void jMenuItemSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSalvarActionPerformed
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("Arquivos texto", "txt", "dat", "java"));
       int a = fileChooser.showSaveDialog(null);

        if (a == JFileChooser.APPROVE_OPTION) {
            File arquivo = new File(fileChooser.getSelectedFile().getAbsolutePath() + ".txt");
            FileWriter writer = null;

            try {
                writer = new FileWriter(arquivo);
                writer.write(codigoFonte.getText());
                writer.close();
            } catch (IOException exception) {
            }
             jTabbedPane3.setTitleAt(0, fileChooser.getSelectedFile().getName());


        }       // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemSalvarActionPerformed

    private void jMenuItemAbrirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAbrirActionPerformed
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setDialogTitle("Abrir Código");
        fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
        fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("Arquivos textos", "txt", "dat", "java"));

        int a = fileChooser.showOpenDialog(null);
        if (a == JFileChooser.APPROVE_OPTION) {
            try {
                FileReader reader = new FileReader(fileChooser.getSelectedFile());
                BufferedReader breader = new BufferedReader(reader);
                int contador = 1;
                String line = "";
                String aux = "";
                do {
                    try {
                        line = breader.readLine();
                        if (line != null) {
                            aux = aux + line;
                            aux = aux + "\n";
                        }

                    } catch (IOException ex) {
                        Logger.getLogger(Janela.class.getName()).log(Level.SEVERE, null, ex);
                    }

                } while (line != null);
                 jTabbedPane3.setTitleAt(0, fileChooser.getSelectedFile().getName());
                codigoFonte.setText(aux);
            } catch (FileNotFoundException ex) {
                Logger.getLogger(Janela.class.getName()).log(Level.SEVERE, null, ex);
            }
        }        // TODO add your handling code here:
 
// TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemAbrirActionPerformed

    private void novoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_novoActionPerformed
    
        
        if(!codigoFonte.getText().equals(""))
        {
            int resposta2 = JOptionPane.showConfirmDialog(null, "Deseja salvar a edição do código?",
                    "Novo", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

            if (resposta2 == JOptionPane.YES_OPTION) {
                salvarActionPerformed(evt);
                codigoFonte.setText("");
            }
            else if (resposta2 == JOptionPane.NO_OPTION) {
                codigoFonte.setText("");
            }
    }
         this.jTextAreaErros.setText("");
         jTabbedPane3.setTitleAt(0, "Novo arquivo");

        //Apaga as linhas da tabela de tokens
        jTableTokens.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Linha", "Token", "Tipo", "Valor"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };
        });

                // TODO add your handling code here:
    }//GEN-LAST:event_novoActionPerformed

    private void jMenuItemNovoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNovoActionPerformed
if(!codigoFonte.getText().equals(""))
        {
            int resposta2 = JOptionPane.showConfirmDialog(null, "Deseja salvar a edição do código?",
                    "Novo", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);

            if (resposta2 == JOptionPane.YES_OPTION) {
                salvarActionPerformed(evt);
                codigoFonte.setText("");
            }
            else if (resposta2 == JOptionPane.NO_OPTION) {
                codigoFonte.setText("");
            }
    }
         this.jTextAreaErros.setText("");
         jTabbedPane3.setTitleAt(0, "Novo arquivo");

        //Apaga as linhas da tabela de tokens
        jTableTokens.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Linha", "Token", "Tipo", "Valor"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };
        });        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemNovoActionPerformed

    private void jMenuItemSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemSairActionPerformed
        this.dispose();
        System.exit(0);        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemSairActionPerformed

    private void executarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_executarActionPerformed
        if(this.codigoFonte.getText().equals("")){
            JOptionPane.showMessageDialog(null, "É nessessário um código aberto para executar");
            return;
        }

        //Limpa os campos para uma nova execução
        this.limparActionPerformed(evt);

        //Cria uma instancia do compilador
        Compilador333 c = new Compilador333(this, this.codigoFonte.getText());

        //Inicia a Thread de compilação
        compilador = new Thread(c);
        compilador.start();
    }//GEN-LAST:event_executarActionPerformed

    private void cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarActionPerformed
        //Interrompe a Thread de compilação
        compilador.interrupt();
    }//GEN-LAST:event_cancelarActionPerformed

    private void limparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_limparActionPerformed

        //Apaga o campo de erros
        this.jTextAreaErros.setText("");

        //Apaga as linhas da tabela de tokens
        jTableTokens.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Linha", "Token", "Tipo", "Valor"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };
        });
    }//GEN-LAST:event_limparActionPerformed

    private void jMenuItemLimparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemLimparActionPerformed
 //Apaga o campo de erros
        this.jTextAreaErros.setText("");

        //Apaga as linhas da tabela de tokens
        jTableTokens.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Linha", "Token", "Tipo", "Valor"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };
        });        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemLimparActionPerformed

    private void jButtonAjudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAjudaActionPerformed
        new Ajuda().setVisible(true);
    }//GEN-LAST:event_jButtonAjudaActionPerformed

    private void jMenuItemAjudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAjudaActionPerformed
    new Ajuda().setVisible(true);        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItemAjudaActionPerformed

    public void imprimeErro (String erro) {

        jTextAreaErros.append(erro+'\n');
        jTextAreaErros.setForeground(Color.red);

      }

    public void imprimeToken (String token, String tipo, String valor, int linha) {

       DefaultTableModel modelo = (DefaultTableModel) jTableTokens.getModel();

       String line = null;
       line = String.valueOf(linha);

       String[] dados = {line,token,tipo,valor};

       modelo.addRow(dados);

      }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Janela().setVisible(true);
                
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton abrir;
    private javax.swing.JButton cancelar;
    private javax.swing.JTextArea codigoFonte;
    private javax.swing.JButton executar;
    private javax.swing.JButton jButtonAjuda;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItemAbrir;
    private javax.swing.JMenuItem jMenuItemAjuda;
    private javax.swing.JMenuItem jMenuItemLimpar;
    private javax.swing.JMenuItem jMenuItemNovo;
    private javax.swing.JMenuItem jMenuItemSair;
    private javax.swing.JMenuItem jMenuItemSalvar;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTabbedPane jTabbedPane3;
    private javax.swing.JTable jTableTokens;
    private javax.swing.JTextArea jTextAreaErros;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JButton limpar;
    private javax.swing.JButton novo;
    private javax.swing.JButton salvar;
    // End of variables declaration//GEN-END:variables

}
